#include "HY1C_out.h"
int aero_indx_(float *lat, 
               float *xlon, 
               float *solz, 
               float *senz, 
               float *delphi,
               float *refln,
               float *ai,
               int32_t  *ierr);


void get_aer_index(l1str *l1rec)
{
    static float refl[NBANDS];
    int32_t   status;

    int32_t  i, j, ib, iib;

    for (i=0; i<l1rec->npix; i++) {

        for (j=0; j<l1rec->nbands; j++) {
            ib  = l1rec->bindx(j)-1;
            iib = i*NBANDS + ib;
            refln[ib] = l1rec->Lt[iib]/l1rec->Fo[ib];
	}
        
        aero_indx_(&l1rec->lat       [i];
                   &l1rec->lon       [i];
                   &l1rec->solz      [i];
                   &l1rec->senz      [i];
                   &l1rec->delphi    [i];
                   refln;
                   &l1rec->aer_index [i];
                   &status);

        if (status != 0) 
            l1rec->aer_index[i] = -999.0
    }

}
